import 'package:flutter/material.dart';
import './ProductEdit.dart';
import './ProductList.dart';
import '../Models/product.dart';

class ProductAdmin extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print('[Products Widget] build');
    // TODO: implement build
    return DefaultTabController(
      length: 2,
      child: Scaffold(
          drawer: Drawer(
              child: Column(
            children: <Widget>[
              AppBar(
                automaticallyImplyLeading: false,
                title: Text('choose'),
              ),
              ListTile(
                title: Text('All Product'),
                onTap: () {
                  //跳转到 '/'路由
                  Navigator.pushReplacementNamed(context, '/');
                },
              )
            ],
          )),
          appBar: AppBar(
            title: Text("Manage Product"),
            bottom: TabBar(tabs: <Widget>[
              Tab(
                icon: Icon(Icons.create),
                text: 'create',
              ),
              Tab(
                icon: Icon(Icons.list),
                text: 'list',
              )
            ]),
          ),
          body: TabBarView(
            children: <Widget>[ProductEdit(), ProductList()],
          )),
    );
  }
}
